#include "EpollServer.hpp"


int DoTask(int sock)
{
    char buffer[1024];
    ssize_t rd = recv(sock, buffer, sizeof(buffer) - 1, 0);
    if (rd > 0)
    {
        buffer[rd] = 0;
        cout << "客户端发送消息[" << sock << "]：" << buffer << endl;
    }
    return rd; 
}

int main(int argc, char* argv[])
{
    if (argc != 2)
        exit(1);
    
    unique_ptr<EpollServer> server(new EpollServer(atoi(argv[1]), DoTask));
    server->init();
    server->run();
    return 0;
}